# Maintainer: Jerome Leclanche <jerome@leclan.ch>
# Maintainer: Chih-Hsuan Yen <yan12125@archlinux.org>

pkgname=qtermwidget
pkgver=1.3.0
pkgrel=2
pkgdesc="A terminal widget for Qt, used by QTerminal"
arch=("loong64" "x86_64")
url="https://github.com/lxqt/$pkgname"
# Yep, it's messy when you're talking about licenses
license=("LGPL" "custom:BSD" "custom:Public Domain")
depends=("qt5-base")
makedepends=("lxqt-build-tools"
            "python-pyqt5" "pyqt-builder" "sip" "python-installer")
optdepends=(
  'python: PyQt5 bindings'
)
source=(
  "https://github.com/lxqt/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.xz"
  "https://github.com/lxqt/$pkgname/releases/download/$pkgver/$pkgname-$pkgver.tar.xz.asc"
)
sha256sums=('74bea8a12bb718e3d6233d04bfe131b0d0d33ab25a9c018c9a145c6b5aa5804e'
            'SKIP')
validpgpkeys=(
  "169704C6FB490C6892C7F23C37E0AF1FDA48F373"  # Jerome Leclanche <jerome@leclan.ch>
  "7C733BA5F585AAD669E4D23A42C9C8D3AF5EA5E3"  # Alf Gaida <agaida@siduction.org>
  "19DFDF3A579BD509DBB572D8BE793007AD22DF7E"  # Pedram Pourang <tsujan2000@gmail.com>
)

build() {
  mkdir -p build
  cd build

  cmake "$srcdir/$pkgname-$pkgver" \
    -DCMAKE_INSTALL_PREFIX=/usr
  make

  cd "$srcdir/$pkgname-$pkgver"/pyqt
  CXXFLAGS="-I$PWD/../lib -I$PWD/../../build/lib" LDFLAGS="-L$PWD/../../build" sip-wheel --verbose
}

package() {
  cd build
  make DESTDIR="$pkgdir" install
  install -Dm644 "$srcdir/$pkgname-$pkgver/README.md" -t "$pkgdir"/usr/share/licenses/$pkgname

  cd "$srcdir/$pkgname-$pkgver"/pyqt
  python -m installer --destdir="$pkgdir" *.whl
}
